package com.example.keli.ui.my.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.keli.R;
import com.example.keli.base.utils.DensityUtil;
import com.example.keli.base.utils.GlideUtil;
import com.example.keli.base.utils.ScreenUtil;
import com.example.keli.ui.my.model.InviteUserVO;
import com.example.keli.ui.userinfo.UserInfoDialog;

import java.util.List;

/**
 * description:
 * author: Allen
 * date: 2019/3/19 11:51
 */
public class InviteUserAdapter extends BaseQuickAdapter<InviteUserVO, BaseViewHolder> {

    int width = 173 * 2;
    int height = 220 * 2;

    public InviteUserAdapter(List<InviteUserVO> mData, Context context) {
        super(R.layout.item_info_common, mData);
        width = (ScreenUtil.getScreenWidth(context) - DensityUtil.dip2px(context, 30)) / 2;
        height = width * 220 / 173;
    }

    @Override
    protected void convert(BaseViewHolder helper, final InviteUserVO mListBean) {
        helper.setText(R.id.tv_name, mListBean.getNickname());
        helper.setVisible(R.id.tv_subtitle, true);
        helper.setText(R.id.tv_subtitle, String.format("注册时间:  %s", mListBean.getAdd_time()));
        ImageView cover = helper.getView(R.id.iv_avatar);
        GlideUtil.display(cover.getContext(), cover, mListBean.getAvatar());
        cover.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new UserInfoDialog(mContext, mListBean.getId()).show();
            }
        });
    }

}
